Create a new role
This request is used to create a record for a new user role.
Request syntax
POST https://business.taxi.yandex.ru/api/1.0/client/{client ID}/role/
🔴 We recommend using API 2.0. API 1.0 support will be discontinued in the future.
Request headers:
Authorization
OAuth access token. The steps to get a token are described in Getting started.
Data for the new role is passed in the request body in JSON format:
|
Field |
Description |
Format |
|
|
The name of the new role. This parameter must be unique among the existing client roles. |
String |
|
|
A list of available classes. |
Array |
|
|
The limits on the amount a user can spend on rides in a calendar month. |
String |
|
|
Department identification number. |
String |
|
|
Indicates that this role doesn't have a limit on the total ride cost. Possible values:
Optional field. |
Logical |
|
|
A block with information about the role restrictions. |
Array of objects |
|
|
The restriction type. Possible values:
|
String |
|
|
Days of the week when ride orders are available. Possible values:
This field is only used for |
Array of strings |
|
|
The time when the order becomes available. Value format: This field is only used for |
String |
|
|
The time when the order will no longer be available. Value format: This field is only used for |
String |
|
|
The date when the order becomes available. Value format: This field is used only for |
String |
|
|
The date when the order will no longer be available. Value format: |
String |
|
|
A block that contains information about non-restricted ride regions. |
Array of objects |
|
|
Starting ride region ID. If the field is left empty, then any region is allowed. At least the |
String |
|
|
Ending ride region ID. If the field is left empty, then any region is allowed. At least the |
String |
|
|
Indicates that rides can go in either direction.
Optional field. Default value: |
Logical |
Response field description
Responses may contain the following fields:
| Field | Description | Format |
|---|---|---|
_id |
The role ID. | String |
Example requests
Create a role with restrictions by day of the week and ride region.
POST https://business.taxi.yandex.ru/api/1.0/client/a2...d09/role/
...
Authorization: <OAuth token>
{
"name": "Test role 1",
"classes": [
"econom"
],
"limit": "100000",
"department_id": "233e725b0511459da7b38cb24f2d8fd7",
"restrictions": [
{
"type":"weekly_date",
"end_time":"22:00:00",
"start_time":"23:59:00",
"days":["mo","tu","fr"]
}
],
"geo_restrictions": [
{
"source": "geo_restriction_id1",
"destination": "geo_restriction_id2"
},
{
"source": "geo_restriction_id3"
}
]
}
Creating a role with restrictions by date
POST https://business.taxi.yandex.ru/api/1.0/client/a2...d09/role/
...
Authorization: <OAuth token>
{
"name": "Test role 2",
"classes": [
"econom"
],
"limit": "100000",
"department_id": "233e725b0511459da7b38cb24f2d8fd7",
"restrictions": [
{
"type": "range_date",
"start_date": "2019-01-15T14:35:00",
"'end_date": "2019-06-15T14:35:00"
}
]
}
Response example
An example response to this request looks like this:
{
"_id": "3caa3587675b49deb62e3286b753b05e"
}
Response codes
The response to this request may contain the following standard HTTP codes:
200: Request completed successfully.400: An unknown parameter or a parameter with an invalid value was passed in the request.401: The OAuth token is incorrect.403: The client doesn't have sufficient rights to execute this request.406: A record with the specified data already exists.